package kr.or.ddit.web.listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import lombok.extern.slf4j.Slf4j;

/**
 * Application Lifecycle Listener implementation class MySessionListener
 *
 */

@Slf4j	// 로깅남기기용으로
@WebListener	// 이 어노테이션을 쓰면 따로 웹.xml에 등록을 따로 할필요 없음.. 알아서 해줌/톰캣7.0부터가능
public class MySessionListener implements HttpSessionListener {
	public static int count;

    /**
     * Default constructor. 
     */
    public MySessionListener() {
        // TODO Auto-generated constructor stub
    }

	/**
     * @see HttpSessionListener#sessionCreated(HttpSessionEvent)
     */
    public void sessionCreated(HttpSessionEvent arg0) {
       log.info("세션 생성 : "+arg0.getSession().getId());
       count++;
    }

	/**
     * @see HttpSessionListener#sessionDestroyed(HttpSessionEvent)
     */
    public void sessionDestroyed(HttpSessionEvent arg0) {
    	log.info("세션 스탑 : "+arg0.getSession().getId());
    	count--;
    }
	
}
